Hall Current 5 Click
Hall Current 5 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : MikroE Team
- Date : Dec 2019.
- Type : ADC type
Software Support
Example Description
The demo application reads ADC value and current value.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.HallCurrent5
Example Key Functions
- hallcurrent5_cfg_setup Config Object Initialization function.
void hallcurrent5_cfg_setup(hallcurrent5_cfg_t *cfg)
Config Object Initialization function.
Click configuration structure definition.
Definition hallcurrent5.h:114
- hallcurrent5_init Initialization function.
HALLCURRENT5_RETVAL hallcurrent5_init(hallcurrent5_t *ctx, hallcurrent5_cfg_t *cfg)
Initialization function.
Click ctx object definition.
Definition hallcurrent5.h:97
- hallcurrent5_default_cfg Click Default Configuration function.
- hallcurrent5_set_adc_resolution This function sets ADC resolution.
void hallcurrent5_set_adc_resolution (
hallcurrent5_t *ctx,
float adc_res );
- hallcurrent5_get_adc_voltage This function gets ADC voltage.
float hallcurrent5_get_adc_voltage (
hallcurrent5_t *ctx, uint16_t adc_value );
- hallcurrent5_get_current This function gets ADC current value.
float hallcurrent5_get_current(hallcurrent5_t *ctx)
Get ADC current value function.
Application Init
Initialization device and ADC Init.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
hallcurrent5_set_adc_resolution( &hallcurrent5, HALLCURRENT5_ADC_RESOLUTION_12bit );
Delay_100ms();
}
#define HALLCURRENT5_MAP_MIKROBUS(cfg, mikrobus)
Definition hallcurrent5.h:65
void hallcurrent5_set_init_voltage(hallcurrent5_t *ctx, uint16_t voltage)
Get ADC current value function.
void application_init(void)
Definition main.c:37
Application Task
Reads current value in mA and this data logs to USBUART every 500ms.
{
int16_t adc_value;
uint32_t sum_adc = 0;
uint8_t cnt;
float current;
log_printf( &logger, "** ADC value : [DEC]- %d, [HEX]- 0x%x \r\n", tmp, tmp );
Delay_ms ( 1000 );
sum_adc = 0;
for(cnt = 0; cnt < 20; cnt++)
{
}
adc_value = ( sum_adc / 20 );
if ( current < 0 )
{
current = 0;
}
log_printf( &logger, " ADC value: %d \r\n", adc_value);
log_printf( &logger, " Current : \r\n", adc_value);
Delay_ms ( 500 );
}
hallcurrent5_data_t hallcurrent5_generic_read(hallcurrent5_t *ctx)
Generic read function.
uint16_t hallcurrent5_data_t
Analog data type.
Definition hallcurrent5.h:91
void application_task(void)
Definition main.c:66
Note
Before the start of the program you have to set the starting voltage on AN pin. First, measure the voltage in mV on AN pin, when electronic load isn't > connected to the Click board, and pass that value as an input parameter of the voltage initialization function.
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.